<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">公告管理</h5>
        <button class="btn btn-primary" onclick="showAddNoticeModal()">发布公告</button>
    </div>
    <div class="card-body">
        <!-- 搜索栏和筛选按钮 -->
        <div class="row mb-3">
            <div class="col-md-6">
                <div class="input-group">
                    <input type="text" class="form-control" id="searchKeyword" placeholder="搜索公告...">
                    <button class="btn btn-secondary" onclick="searchNotices()">搜索</button>
                </div>
            </div>
            <div class="col-md-6">
                <div class="btn-group" role="group">
                    <button type="button" class="btn btn-outline-primary" onclick="loadAllNotices()">全部</button>
                    <button type="button" class="btn btn-outline-success" onclick="loadPublishedNotices()">已发布</button>
                    <button type="button" class="btn btn-outline-secondary" onclick="loadDraftNotices()">未发布</button>
                </div>
            </div>
        </div>

        <!-- 公告列表 -->
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>标题</th>
                        <th>发布人</th>
                        <th>发布时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="noticeTableBody">
                    <!-- 动态加载的公告列表 -->
                </tbody>
            </table>
        </div>
    </div>
</div>

<!-- 添加/编辑公告模态框 -->
<div class="modal fade" id="noticeModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="noticeModalTitle">发布公告</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <form id="noticeForm">
                    <input type="hidden" id="noticeId">
                    <div class="mb-3">
                        <label class="form-label">标题</label>
                        <input type="text" class="form-control" id="noticeTitle" required>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">内容</label>
                        <textarea class="form-control" id="noticeContent" rows="5" required></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="saveNotice()">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 查看公告模态框 -->
<div class="modal fade" id="viewNoticeModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="viewNoticeTitle"></h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <div id="viewNoticeContent" style="white-space: pre-wrap;"></div>
                <hr>
                <div class="text-muted">
                    <small>
                        发布人：<span id="viewNoticePublisher"></span><br>
                        发布时间：<span id="viewNoticeTime"></span>
                    </small>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 错误提示模态框 -->
<div class="modal fade" id="errorModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">错误提示</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <p id="errorMessage"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-bs-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>

<!-- 成功提示模态框 -->
<div class="modal fade" id="successModal" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">提示</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
            </div>
            <div class="modal-body">
                <p id="successMessage"></p>
            </div>
        </div>
    </div>
</div> 